package jw.hospital.common.exception;

import jw.hospital.common.result.ResultResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultResponse error(Exception e) {
        e.printStackTrace();
        return ResultResponse.fail();
    }

    //自定义异常
    @ExceptionHandler(HospitalException.class)
    public ResultResponse error(HospitalException e) {
        e.printStackTrace();
       return ResultResponse.fail();

    }


}
